package com.lan.app.utils;

import com.lan.support.boot.SpringUtils;
import com.lan.ot.ClazzOt;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;

import java.util.Map;

public class LanUtils {

    public static NamedParameterJdbcTemplate template() {
        return SpringUtils.getBean(NamedParameterJdbcTemplate.class);
    }

    public static SqlDao sqlDao() {
        return SpringUtils.getBean(SqlDao.class);
    }


    public static Object save(String sql, ClazzOt param, Boolean isRtn) {
        return sqlDao().save(sql, (Map) param.getData(), isRtn);
    }

    public static int update(String sql, ClazzOt param) {
        return sqlDao().update(sql, (Map) param.getData());
    }

    public static Object select(ClazzOt param, String sql, Boolean isOne) {
        if (isOne) {
            return sqlDao().select(sql, (Map) param.getData());
        } else {
            return sqlDao().selectList(sql, (Map) param.getData());
        }
    }

}
